﻿using UnityEngine;
using System.Collections;

public class AsteroidGenerator : MonoBehaviour 
{
    public int asteroidCount;
    public float asteroidMinSize;
    public float asteroidMaxSize;
    public float asteroidMinRange;
    public float asteroidMaxRange;

	private void Start () 
    {
        for (int i = 0; i < asteroidCount; i++)
        {
            GameObject newAsteroid = GameObject.CreatePrimitive(PrimitiveType.Sphere);

            Destroy(newAsteroid.collider);
            newAsteroid.AddComponent<MeshCollider>();
            newAsteroid.AddComponent<Rigidbody>();
            newAsteroid.rigidbody.useGravity = false;
                
            newAsteroid.transform.position = Random.insideUnitSphere * Random.Range(asteroidMinRange, asteroidMaxRange);
            newAsteroid.transform.localScale = new Vector3(
                Random.RandomRange(asteroidMinSize, asteroidMaxSize),
                Random.RandomRange(asteroidMinSize, asteroidMaxSize),
                Random.RandomRange(asteroidMinSize, asteroidMaxSize));



            newAsteroid.name = "Asteroid" + i;
        }
	}
}
